package first.program;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
public class PrefScreen extends Activity{
    protected static final int feedbackConstant = 3;
	public static final String PREFS_NAME = "MyPrefsFile";
	
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.prefscreen);
        
        final CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox1);
        SharedPreferences cx= getSharedPreferences(PREFS_NAME, 0);
        checkBox.setChecked(cx.getBoolean("rand", false));
        
        Button done = (Button) findViewById(R.id.done);
        done.setOnClickListener(new View.OnClickListener() {
        	
            public void onClick(View view) {
            	view.performHapticFeedback(feedbackConstant , 0);
                Intent myIntent = new Intent(view.getContext(), MasterMindActivity.class);
                startActivityForResult(myIntent, 0);
                
            }

        });
        
        
    }
   

    
    @Override
    protected void onStop(){
       super.onStop();
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
       SharedPreferences.Editor editor = settings.edit();
       final CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox1);
       if (checkBox.isChecked()) {
    	   editor.putBoolean("rand", true);
    	   Log.i("cs","shit be true");
       }
       else
       {
    	   editor.putBoolean("rand", false);
    	   Log.i("cs","shit be false");
    	   
       }
       
      editor.commit();
    }
    
   	@Override
   	public void onBackPressed(){
   	return;	
   	}

}